package com.uottawa.clickerapp.domain;

import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

import com.uottawa.clickerapp.dao.impl.*;

@XmlRootElement
public class Question extends DataStoreEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2781881383140180324L;
	private long ID;
	private String questionText;
	private long questionSessionID;
	private boolean enabled;
	private boolean multipleSubmit;

	private List<Answer> answers;
	
	public Question(){
		
	}
	
	public Question(long questionSessionID, String text){
		this.questionSessionID = questionSessionID;
		this.questionText = text;
		enabled = false;
	}
	
	public boolean canMultipleSubmit() {
		return multipleSubmit;
	}

	public void setMultipleSubmit(boolean multipleSubmit) {
		this.multipleSubmit = multipleSubmit;
	}
	
	public String getQuestionText() {
		return questionText;
	}
	public void setQuestionText(String questionText) {
		this.questionText = questionText;
	}
	public long getQuestionSessionID() {
		return questionSessionID;
	}
	public void setQuestionSessionID(long questionSessionID) {
		this.questionSessionID = questionSessionID;
	}
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	public List<Answer> getAnswers(){
		return answers;
	}
	
	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}

	public void save(){
		SQLDBHelper.store(this);
	}

	public void fetch(){
		if (this.ID != 0){ 
			SQLDBHelper.fetch(this);
		}
	}
	
	public void delete(){
		SQLDBHelper.delete(this);
	}
	

}
